1. Field of the Invention
This invention relates to an image recognition method and an image recognition apparatus for recognizing a plurality of images to be recognized, including a specific image and images provided by rotating the specific image from an input image, and a recording medium recording a program for accomplishing image recognition by the image recognition method.
2. Description of the Related Art
A template matching method is widely known as a method of recognizing a specific image from an input image. A general template matching method is as follows:
A specific image to be recognized is provided as a reference image, an input image is superposed on the reference image and a comparison is made between the images while both the images are slid relatively one pixel at a time horizontally or vertically. If all the pixels or a given number of pixels or more match, it is determined that the specific image is contained in the input image.
In this method, however, for example, if the specific image is rotated, the image matching the reference image cannot be recognized from the input image containing the specific image rotated. That is, the method has the disadvantage in that if the specific image in the input image differs from the reference image in orientation, the specific image cannot be recognized.
Proposed as a conventional method for overcoming the disadvantage is an image recognition method capable of recognizing a specific image at various rotation angles by storing the coordinates of a reference pattern (corresponding to a reference image) in memory, generating the coordinates applied when the reference pattern is rotated based on the coordinates stored in the memory, and using the generated coordinates and the coordinates stored in the memory for comparison, as disclosed in Japanese Patent Laid-Open No. Hei 5-12446.
As another method for overcoming the disadvantage, Japanese Patent Laid-Open No. Hei 8-63604 describes an image processing method of detecting the center of gravity of an image, representing the contours of the image by polar coordinate data with the center of gravity as the center, and comparing the function represented by the polar coordinate data with the function responsive to the contours of a reference image, thereby determining similarity between the images in shape. This method also copes with a rotated specific image by grasping a function phase shift as rotation of the specific image.
Further, Japanese Patent Laid-Open No. Hei 6-309461 describes an image recognition method of recognizing a specific image by applying Fourier transform to a light and dark pixel data string provided by scanning an image on the circumference of a circular window to find a spectrum pattern and comparing the spectrum pattern with a spectrum pattern of a reference image. This method also copes with a rotated specific image because the provided spectrum pattern does not depend on the scanning start position (rotation angle of the specific image) and becomes identical.
However, as seen from the description made so far, the above-described methods disclosed in the gazettes must perform complicated operations at the image recognition time and cannot be applied to uses requiring high-speed processing. If an attempt is made to realize each of the above-described methods in circuitry, namely, hardware to speed up processing, the circuit configuration becomes large-scaled and complicated.
Particularly, in recent years, a system of embedding a specific image in an image as code information representing copyright information, distribution path information, etc., of the image or a specific image as code information specifying processing to be performed for the image for using the code information to handle the image has been proposed; they look forward to realizing an inexpensive image recognition apparatus that can recognize a specific image at high speed.
It is therefore an object of the invention to provide an image recognition method and an image recognition apparatus capable of recognizing a specific image at high speed in a simple configuration with recognition accuracy independent of the orientation (rotation angle) of the specific image, and a recording medium recording a program for accomplishing the image recognition according to the image recognition method.
To the end, according to a first aspect of the invention, there is provided an image recognition method of recognizing a plurality of images from an input image, the plurality of images to be recognized including at least one of a specific image and images provided by rotating the specific image, the method including the steps of: preparing at least one of mask areas on a window area for each image to be recognized, the window area being structured by cells which are arrayed in two-dimensionally, the cell being formed of at least one pixel, the mask area being structured by at least one of the cells and corresponding to an area representing a feature of the image to be recognized; first determining whether or not the image to be recognized exists based on the result of subjecting pixel density values of the input image in the mask area to operation for each image to be recognized; and second determining whether or not any of the plurality of images to be recognized exists in the window area based on the determination result of the first determining step.
Further, whether or not the image to be recognized exists may be determined considering not only the operation result performed on the pixel density values in the mask areas, but also the operation result performed on the pixel density values in the window area outside the mask areas, in which case the recognition accuracy can be improved. Alternatively, whether or not there is a possibility that any of the images to be recognized exists in the window area rather than whether or not any of the images to be recognized exists in the window area may be determined.
Further, the images to be recognized may be images provided by rotating the specific image at arbitrary angles with the same center position as the center, in which case the image to be recognized can be defined only from the corresponding rotation angle. Further, the mask areas may be placed with the same center position matched with the center position of the window area, in which case setting of the mask areas is facilitated and the size of the window area can be minimized.
In addition, considering that as a pixel is distant from the center position of rotation, the move distance of the pixel becomes large when the pixel is rotated, the window area may be formed so that as each mask area is distant from the center position of the window area, the number of the cells making up the mask area increases, whereby the recognition miss occurrence probability can be decreased.
Further, the mask areas for the images to be recognized may be calculated and set based on the mask areas set for any one of the images to be recognized and the rotation angles of the images to be recognized. That is, the mask areas can be set easily. The mask areas corresponding to a plurality of specific images to be recognized and the images to be recognized, provided by rotating the specific images may be set on a single window area. The input image may be a binary image, in which case operation processing can be more simplified and the system scale can be more reduced.
According to a second aspect of the invention, there is provided an image recognition apparatus of recognizing a plurality of images from an input image, the plurality of images to be recognized including at least one of a specific image and images provided by rotating the specific image, the apparatus including: an image data storage unit for storing image data representing the input image; a mask area storage unit for storing setup information so as to set at least one of mask areas on a predetermined window area for each of the images to be recognized; a mask area operation unit for operating values of the image data in the mask areas for each image to be recognized; an image determination unit for determining whether or not the image to be recognized exists based on the operation result of the mask area operation unit for each image to be recognized; and a specific image recognition unit for determining whether or not any of the images to be recognized exists in the window area based on the determination result of the image determination unit for each image to be recognized. In this case, the mask area storage unit itself or a storage section is exchanged, whereby any images to be recognized can be handled.
The image recognition apparatus may further include an outside-mask-area operation unit for performing operation on values of the image data in the window area outside the mask areas for each image to be recognized, wherein the image determination unit may determine whether or not the image to be recognized exists based on the operation result of the mask area operation unit and the operation result of the outside-mask-area operation unit for each image to be recognized. Alternatively, the image determination unit may determine whether or not there is a possibility that the image to be recognized exists based on the operation result of the mask area operation unit for each image to be recognized, and the specific image recognition unit may determine whether or not there is a possibility that any of the images to be recognized exists in the window area based on the determination result of the image determination unit for each image to be recognized.
Further, if the storage contents of the mask area storage unit can be read and write arbitrarily, the mask area setup information can be changed easily.
By the way, to reliably recognize each image to be recognized, it is necessary to extract areas and set mask areas considering that the darkness values of the pixels making up the image to be recognized vary due to various factors. However, if the variations are considered to set wide mask areas for all areas, the possibility that an image similar to the image to be recognized will be erroneously recognized as the image to be recognized particularly in the portion near to the center position becomes high. Then, the mask area nearest to the center position of the window area is formed of only one cell and other mask areas are set with the mask area as the reference, whereby the erroneous recognition occurrence probability can be decreased.
The window area may be rectangular or circular and the mask areas may be set arbitrarily. If the window area is rectangular, input images which generally become often rectangular can be scanned without omission and scanning processing can be simplified. If the window area is circular, the pixel positions on the window area can be represented in polar coordinates, thus the capacity required for storing the mask areas can be decreased. Further, the mask areas can be set arbitrarily, whereby the mask areas can be set in response to the characteristics of an input image and the recognition accuracy can be improved. Of course, all types of images can also be set to the images to be recognized.
The setup information stored in the mask area storage unit may contain the setup information of the mask areas set for any one of the images to be recognized and the rotation angles of the images to be recognized. In this case, the capacity required for storing the mask area setup information can be decreased. Of course, the image data may be binary data for avoiding complexity of the circuit configuration and the apparatus or processing for each image to be recognized may be performed in parallel in the same cycle for realizing real-time processing.
According to a third aspect of the invention, there is provided a recording medium recording a program for recognizing a plurality of images from an input image, the plurality of images to be recognized including at least one of a specific image and images provided by rotating the specific image, the program including the steps of: preparing at least one of mask areas on a window area for each image to be recognized, the window area being structured by cells which are arrayed in two-dimensionally, the cell being formed of at least one pixel, the mask area being structured by at least one of the cells and corresponding to an area representing a feature of the image to be recognized; first determining whether or not the image to be recognized exists based on the result of subjecting pixel density values of the input image in the mask area to operation for each image to be recognized; and second determining whether or not any of the plurality of images to be recognized exists in the window area based on the determination result of the first determining step.